package cn.gemiman.daoyi.module.cms.dal.mysql.articlecategory;

import cn.gemiman.daoyi.framework.common.pojo.PageResult;
import cn.gemiman.daoyi.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.gemiman.daoyi.framework.mybatis.core.mapper.BaseMapperX;
import cn.gemiman.daoyi.module.cms.dal.dataobject.articlecategory.CmsArticleCategoryDO;
import org.apache.ibatis.annotations.Mapper;
import cn.gemiman.daoyi.module.cms.controller.admin.articlecategory.vo.*;

/**
 * 文章栏目 Mapper
 *
 * @author 道一源码
 */
@Mapper
public interface CmsArticleCategoryMapper extends BaseMapperX<CmsArticleCategoryDO> {

    default PageResult<CmsArticleCategoryDO> selectPage(CmsArticleCategoryPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<CmsArticleCategoryDO>()
                .eqIfPresent(CmsArticleCategoryDO::getAppSiteId, reqVO.getAppSiteId())
                .eqIfPresent(CmsArticleCategoryDO::getAppId, reqVO.getAppId())
                .eqIfPresent(CmsArticleCategoryDO::getParentId, reqVO.getParentId())
                .likeIfPresent(CmsArticleCategoryDO::getTitle, reqVO.getTitle())
                .likeIfPresent(CmsArticleCategoryDO::getSubTitle, reqVO.getSubTitle())
                .eqIfPresent(CmsArticleCategoryDO::getNavBar, reqVO.getNavBar())
                .eqIfPresent(CmsArticleCategoryDO::getStatus, reqVO.getStatus())
                .eqIfPresent(CmsArticleCategoryDO::getViewNum, reqVO.getViewNum())
                .betweenIfPresent(CmsArticleCategoryDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(CmsArticleCategoryDO::getViewNum)
                .orderByDesc(CmsArticleCategoryDO::getId));
    }

}
